/* -----------------------------------------------------------------------------
 * PROJECT    : net.lwf
 * FILE       : WhatIsThisHandler.java
 *
 * HISTORY:
 * Date          Author                        Description
 * ----------------------------------------------------------------------------- 
 * Jan 30, 2009  Raghu Sarraff	 		        Created
 */
package lwf.handler.english.word;

import net.lwf.handler.util.ImageHtml;
import lwf.handler.english.WordHandler;

public class WhatIsThisHandler extends WordHandler {
	
	private String type;
	
	public WhatIsThisHandler(String type, int index, int limit, String data) {
		this.type = type.substring(0, type.trim().length()-1);
        setDisplayData(index, limit, data);
	}
	
	//----------------------------------------------------------------------------------------------
	// Overridden methods
	//----------------------------------------------------------------------------------------------
	public String getFormattedDisplay() {
		String data = super.getFormattedDisplay();
		StringBuffer sbAlphabet = new StringBuffer();
		sbAlphabet.append("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
			sbAlphabet.append("<tr>");
			    sbAlphabet.append("<td class=\"qmediumcenter\" >");
		        	sbAlphabet.append("What is this " + this.type + "?");
		        sbAlphabet.append("</td>");
			sbAlphabet.append("</tr>");
			sbAlphabet.append("<tr>");
		    	sbAlphabet.append("<td>&nbsp;</td>");
		    sbAlphabet.append("</tr>");
			sbAlphabet.append("<tr>");
			    sbAlphabet.append("<td>");
			        sbAlphabet.append(super.getFormattedDisplay());
			    sbAlphabet.append("</td>");
			sbAlphabet.append("</tr>");
			sbAlphabet.append("<tr>");
	    		sbAlphabet.append("<td align=\"center\" >");
	    		sbAlphabet.append("Click <a href=\"#\" class=\"bluelink\" onclick=\"displayAnswer()\">here</a> to see the answer");
	    		sbAlphabet.append("<td>");
	        sbAlphabet.append("</tr>");
	    sbAlphabet.append("</table>");
	    return sbAlphabet.toString();
	}
	
	protected String processRowData(Object obj) {
		if (obj != null) {
			return ImageHtml.getWordImage((String) obj);
		}
		return "";
	} //processRowData

} //WhatIsThisHandler

